﻿using BaseData.API.Write.Applications.AppointmentIng.AppointCommand;
using BaseData.Domain.Appointment;
using BaseData.ErrorCode;
using BaseData.Infrastructure.Interfaces;
using MediatR;

namespace BaseData.API.Write.Applications.AppointmentIng.AppointCommandHandler
{
    /// <summary>
    /// 预约列表添加
    /// </summary>
    public class AppointAddCommandHandler : IRequestHandler<AppointAddCommand, ApiResult<int>>
    {
        IBaseRepository<Appointments> appoinRep;

        public AppointAddCommandHandler(IBaseRepository<Appointments> appoinRep)
        {
            this.appoinRep = appoinRep;
        }

        public async Task<ApiResult<int>> Handle(AppointAddCommand request, CancellationToken cancellationToken)
        {

            await appoinRep.AddAsync(request.appointments);

            return new ApiResult<int>()
            {
                Code=ApiEnum.添加成功,
                Message="",
                Data=1
            };
        }
    }
}
